﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using connect;
using Pharmacy_management_system;
using System.Collections;

namespace Pharmacy_management_system
{
    public partial class chufang : Form
    {
        public chufang()
        {
            InitializeComponent();
        }

        private void chufang_Load(object sender, EventArgs e)
        {
            string case_id = Form1.cfz;
            SqlConnection con1 = new SqlConnection(SQL.constr);
            SqlConnection con2 = new SqlConnection(SQL.constr);
            SqlConnection con3 = new SqlConnection(SQL.constr);
            string cmdText1 = "exec [Get_Patient_info]'" + case_id + "'";
            string cmdText2 = "select order_text,isnull(drug_spec,''),'用法：'+isnull(route_name,''),isnull(dose,'')+isnull(dose_units,'')+'/次',frequency from pt_orders  where order_class='1' and case_id='" + case_id + "'";
            string cmdText3 = "select drugcost from dbo.pt_cost_main where case_id='" + case_id + "'";
            con1.Open();
            con2.Open();
            con3.Open();
            SqlCommand cmd1 = new SqlCommand(cmdText1, con1);
            SqlCommand cmd2 = new SqlCommand(cmdText2, con2);
            SqlCommand cmd3 = new SqlCommand(cmdText3, con3);
            SqlDataReader dr1 = cmd1.ExecuteReader();
            SqlDataReader dr2 = cmd2.ExecuteReader();
            SqlDataReader dr3 = cmd3.ExecuteReader();
            while (dr1.Read())
            {
                label5.Text = dr1[1].ToString();
                label13.Text = dr1[2].ToString();
                label14.Text = dr1[4].ToString();
                label15.Text = dr1[22].ToString();
                label16.Text = dr1[0].ToString();
                label17.Text = dr1[15].ToString();
                label18.Text = dr1[11].ToString();
                label19.Text = dr1[12].ToString();
                label20.Text = dr1[18].ToString();
                label21.Text = dr1[13].ToString();
                label22.Text = dr1[17].ToString();
            }
            dr1.Close();
            con1.Close();
            while (dr2.Read())
            {
                for (int t = 0; t < dr2.FieldCount; t++)
                {
                    richTextBox1.Text += dr2[t].ToString() + "\t";
                    //richTextBox1.Text = richTextBox1.Text + "     用法：" + "\t";
                    //richTextBox1.Text = richTextBox1.Text + dr2[t].ToString() + "\t";
                    //richTextBox1.Text = richTextBox1.Text + dr2[t].ToString() + "\t";
                    //richTextBox1.Text = richTextBox1.Text + dr2[t].ToString() + "\t";
                    //richTextBox1.Text = richTextBox1.Text + dr2[t].ToString() + "\t";
                }
                richTextBox1.Text += "\n";
                richTextBox1.Text += "\n";
            }
            dr2.Close();
            con2.Close();
            while (dr3.Read())
            {
                label26.Text = dr3[0].ToString();
            }
            dr3.Close();
            con3.Close();

   

        }

    }
}
